log: Print a friendly error if we haven't downloaded the complete history
authorColin Walters <walters@verbum.org>
Wed, 11 Jun 2014 20:40:50 +0000 (16:40 -0400)
committerColin Walters <walters@verbum.org>
Wed, 11 Jun 2014 20:41:35 +0000 (16:41 -0400)
For the local repository on the system, it's not the usual case to
have the complete compose history.  Rather than erroring out, provide
a bit more friendly message.

https://bugzilla.gnome.org/show_bug.cgi?id=731538

src/ostree/ot-builtin-log.c

index 0ab134c3fd7db0079592dc7cc2bab479b7672204..89445cd90d8c5da8cdd74ccbd9d6c90f4df9be59 100644 (file)
@@ -37,21 +37,36 @@ static GOptionEntry options[] = {
 static gboolean
 log_commit (OstreeRepo     *repo,
             const gchar    *checksum,
+            gboolean        is_recurse,
             OstreeDumpFlags flags,
             GError        **error)
 {
   gs_unref_variant GVariant *variant = NULL;
   gs_free gchar *parent = NULL;
   gboolean ret = FALSE;
+  GError *local_error = NULL;
 
-  if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, &variant, error))
-    goto out;
+  if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum,
+                                 &variant, &local_error))
+    {
+      if (is_recurse && g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+        {
+          g_print ("<< History beyond this commit not fetched >>\n");
+          g_clear_error (&local_error);
+          ret = TRUE;
+        }
+      else
+        {
+          g_propagate_error (error, local_error);
+        }
+      goto out;
+    }
 
   ot_dump_object (OSTREE_OBJECT_TYPE_COMMIT, checksum, variant, flags);
 
   /* Get the parent of this commit */
   parent = ostree_commit_get_parent (variant);
-  if (parent && !log_commit (repo, parent, flags, error))
+  if (parent && !log_commit (repo, parent, TRUE, flags, error))
     goto out;
 
   ret = TRUE;
@@ -91,7 +106,7 @@ ostree_builtin_log (int           argc,
   if (!ostree_repo_resolve_rev (repo, rev, FALSE, &checksum, error))
     goto out;
 
-  if (!log_commit (repo, checksum, flags, error))
+  if (!log_commit (repo, checksum, FALSE, flags, error))
     goto out;
 
   ret = TRUE;